﻿<!DOCTYPE html>
<!-- 
Template Name:  SmartAdmin Responsive WebApp - Template build with Twitter Bootstrap 4
Version: 4.0.0
Author: Sunnyat Ahmmed
Website: http://www.bootstrapmb.com


-->
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>
            Login - - SmartAdmin v4.0.1
        </title>

        <script src="js/vue.js"></script>
        <script src="js/axios.min.js"></script>
        <script src="js/index.js"></script>
        <link href="css/index.css">
    </head>
    <body>

        <div id="app">
            <div style="margin: 20px;"></div>
            <el-form :label-position="labelPosition" label-width="80px" :model="user">
                <el-form-item label="username">
                    <el-input v-model="user.username"></el-input>
                </el-form-item>
                <el-form-item label="password">
                    <el-input v-model="user.password" show-password></el-input>
                </el-form-item>
                <el-form-item >
                    <el-button @click="login">登录</el-button>
                </el-form-item>
            </el-form>
        </div>







    <script>
            var app = new Vue({
                el:"#app",
                data:{
                    user:{},
                    labelPosition:'right'
                },
                methods:{
                    //用户登陆
                    login() {
                        //发送登陆请求
                        axios.post("http://localhost:8080/admin/login",this.user).then(res=>{
                            if(res.data.statue==1)
                            {
                                alert(res.data.msg);
                                sessionStorage.setItem("token",res.data.token);
                                sessionStorage.setItem("msg",res.data.msg);
                                localStorage.setItem("user",JSON.stringify(res.data.ruser));
                                location.href="http://localhost:8080/upload.html";
                            }else

                            {
                                console.log(res.data.msg);
                                alert(res.data.msg);
                            }
                        });
                    }

                }

            });
        </script>
    </body>
</html>
